package com.sgb.kjwl.view.ui.fragment.manage;

import android.hardware.SensorEventListener;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FrIntroductionForWebsiteBinding;
import com.sgb.kjwl.databinding.LayoutWebsiteInfoGroupMsgBinding;
import com.sgb.kjwl.databinding.LayoutWebsiteInfoOrganizationMsgBinding;
import com.sgb.kjwl.databinding.LayoutWebsiteInfoPersonMsgBinding;
import com.sgb.kjwl.di.manage.DaggerEnterpriseManageFragComponent;
import com.sgb.kjwl.di.manage.EnterpriseManageFragModule;
import com.sgb.link.entity.PickFilterEntity;
import com.sgb.kjwl.model.entity.manage.WebsiteInfoEntity;
import com.sgb.kjwl.view.ui.adapter.manage.AddViewAdapter;
import com.sgb.kjwl.view.widget.manage.WebsiteUtils;
import com.sgb.kjwl.utils.ReplaceUtils;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.adapter.manage.TagAdapter;
import com.sgb.kjwl.view.widget.manage.MImgGetter;
import com.sgb.kjwl.viewmodel.manage.IntroductionForWebsiteModel;
import com.swgk.core.base.di.AppComponent;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

/*
 * Author LiWei
 * Create Time 2021/4/15
 * Description 网站-简介
 * */
public class IntroductionForWebsite extends AppLazyFragment {

    @Inject
    IntroductionForWebsiteModel viewModel;
    private FrIntroductionForWebsiteBinding binding;

    private LayoutWebsiteInfoPersonMsgBinding personMsgBinding;
    private LayoutWebsiteInfoGroupMsgBinding groupMsgBinding;
    private LayoutWebsiteInfoOrganizationMsgBinding organizationMsgBinding;

    private String websiteNo;
    private int websiteType;

    private String noData = "--";
    private String noDataY = "--";

    private SensorEventListener sensorEventListener;

    private TagAdapter mTagAdapter;

    private AddViewAdapter mAddViewAdapter;

    public static IntroductionForWebsite newInstance(String websiteNo, int websiteType) {
        IntroductionForWebsite fragment = new IntroductionForWebsite();
        Bundle args = new Bundle();
        args.putString("websiteNo", websiteNo);
        args.putInt("websiteType", websiteType);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        super.setupFragmentComponent(appComponent);
        DaggerEnterpriseManageFragComponent.builder().appComponent(appComponent)
                .enterpriseManageFragModule(new EnterpriseManageFragModule(this))
                .build()
                .inject(this);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fr_introduction_for_website, container, false);
        if (getArguments() != null) {
            websiteNo = getArguments().getString("websiteNo");
            websiteType = getArguments().getInt("websiteType");
        }
        return binding.getRoot();
    }

    @Override
    protected void initView() {
        if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_PERSONAL){
            binding.nsRoot.removeAllViews();
            personMsgBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.layout_website_info_person_msg, binding.nsRoot, true);
        } else if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_TEAM){
            binding.nsRoot.removeAllViews();
            groupMsgBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.layout_website_info_group_msg, binding.nsRoot, true);
        } else if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_ORGANIZE){
            binding.nsRoot.removeAllViews();
            organizationMsgBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.layout_website_info_organization_msg, binding.nsRoot, true);
        }
        if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_COMPANY){
            mAddViewAdapter = new AddViewAdapter(getContext());
            mAddViewAdapter.setEnableEdit(false);
            binding.addView.setHideAdd();
            binding.addView.setAdapter(mAddViewAdapter);
        }
        binding.smartRefresh.setEnableLoadMore(false);
        // 刷新
        binding.smartRefresh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(@NonNull  RefreshLayout refreshLayout) {
                refreshView();
            }
        });

        binding.rlVideoView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                WebsiteUtils.getInstance().openVideo(getContext(), binding.getViewModel().getVideo(), binding.getViewModel().getVideoUrl(), binding.getViewModel().getCoverUrl());
            }
        });
//        viewModel.getGroupDetailEntityMutableLiveData().observe(this, new Observer<GroupDetailEntity>() {
//            @Override
//            public void onChanged(GroupDetailEntity entity) {
//                if (entity != null) {
//                    showGroupDetail(entity);
//                }
//            }
//        });
    }

    @Override
    protected void onLazyLoad() {
        viewModel.getWebsiteInfo(websiteNo, websiteType);
    }

    /**
     * 显示用户图像
     * @param logo
     */
    private void setAvatarView(String logo, ImageView iv) {

        if (!TextUtils.isEmpty(logo)) {
            int RIcon = R.mipmap.image_website_dfg;
            if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_COMPANY) {
                RIcon = R.mipmap.image_website_dfg;
            } else if (websiteType == WebsiteInfoActivity. WEBSITE_FOR_TEAM) {
                RIcon = R.drawable.icon_team_default;
            } else if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_ORGANIZE){
                RIcon = R.drawable.icon_organization_default;
            }
            RequestOptions options = new RequestOptions()
                    .placeholder(RIcon)//图片加载出来前，显示的图片
                    .error(RIcon);//图片加载失败后，显示的图片
            if (websiteType == WebsiteInfoActivity. WEBSITE_FOR_TEAM) {
                options.transform(new CircleCrop());
            }
            Glide.with(this).load(logo).apply(options).into(iv);
        }
    }

    public void showWebsiteInfo(WebsiteInfoEntity entity) {
        if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_PERSONAL) {
            personMsgBinding.tvManageBusiness.setText(entity.getNewMainBusinessName());
            personMsgBinding.setViewModel(entity);
            setAvatarView(entity.getLogo(), personMsgBinding.ivShopAvatar);
        } else if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_COMPANY) {
            binding.setViewModel(entity);
            if (TextUtils.isEmpty(entity.getIndustryCategoryOneName())) {
                binding.tvIndustryCategory.setText(noData);
            } else {
                if (TextUtils.isEmpty(entity.getIndustryCategoryTwoName())) {
                    binding.tvIndustryCategory.setText(entity.getIndustryCategoryOneName());
                } else {
                    binding.tvIndustryCategory.setText(entity.getIndustryCategoryOneName() + "/" + entity.getIndustryCategoryTwoName());
                }
            }
            if (TextUtils.isEmpty(entity.getCompanyQualityName())) {
                binding.tvCompanyNature.setText(noData);
            } else {
                binding.tvCompanyNature.setText(entity.getCompanyQualityName());
            }
            if (TextUtils.isEmpty(entity.getFixedNumber())) {
                binding.tvFixedNumber.setText(noData);
            } else {
                binding.tvFixedNumber.setText(entity.getFixedNumber());
            }
            if (TextUtils.isEmpty(entity.getConcat())) {
                binding.tvConcat.setText(noData);
            } else {
                binding.tvConcat.setText(entity.getConcat());
            }
            if (TextUtils.isEmpty(entity.getPhone())) {
                binding.tvPhone.setText(noData);
            } else {
                binding.tvPhone.setText(entity.getPhone());
            }
            if (TextUtils.isEmpty(entity.getRecordUnitName())) {
                binding.tvRecordUnitName.setText(noData);
            } else {
                binding.tvRecordUnitName.setText(entity.getRecordUnitName());
            }
            if (TextUtils.isEmpty(entity.getMapAddress())) {
                binding.tvAddress.setText(noData);
            } else {
                binding.tvAddress.setText(entity.getMapAddress() + (TextUtils.isEmpty(entity.getMapAddressDetail()) ? "" : entity.getMapAddressDetail()));
            }
            if (TextUtils.isEmpty(entity.getServiceAreaNames())) {//服务范围
                binding.tvServiceArea.setText(noData);
            } else {
                binding.tvServiceArea.setText(entity.getServiceAreaNames());
            }
            if (!TextUtils.isEmpty(entity.getBusinessInfo().getBusinessModel())){
                binding.jingyingmode.setText(ToDBC(entity.getBusinessInfo().getBusinessModel()));
            }else {
                binding.tvServiceArea.setText(noData);
            }

            binding.tvManageBusiness.setText(entity.getNewMainBusinessName());
//            if (TextUtils.isEmpty(entity.getMarketZone())) {
//                binding.tvArea.setText(noData);
//            } else {
//                List<FilterEntity> filterEntityList = new Gson().fromJson(entity.getMarketZone(), new TypeToken<List<FilterEntity>>() {
//                }.getType());
//                if (filterEntityList.size() > 0) {
//                    StringBuilder builder = new StringBuilder();
//                    int i = 0;
//                    for (FilterEntity areaEntity : filterEntityList) {
//                        if (i < filterEntityList.size() - 1) {
//                            builder.append(areaEntity.getName()).append(",");
//                            i++;
//                        }
//                    }
//                    binding.tvArea.setText(builder);
//                } else {
//                    binding.tvArea.setText(noData);
//                }
//            }
            if (TextUtils.isEmpty(entity.getIntroduction())) {
                binding.tvIntroduction.setText(noData);
                binding.linIntroduction.setVisibility(View.GONE);
            } else {
                binding.tvIntroduction.setText(Html.fromHtml(entity.getIntroduction(), new MImgGetter(getActivity(), binding.tvIntroduction), null));
            }
            if (entity.getBusinessInfo() != null){ //如果有业务类型
                changeViewTip(entity.getBusinessInfo());
                renderView(entity.getBusinessInfo(), entity.getBusinessInfo().getType());
                binding.llBusinessMsg.setVisibility(View.VISIBLE);
                binding.llContent.setVisibility(View.VISIBLE);
                binding.setBusinessType(entity.getBusinessInfo().getType());
            }
        } else if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_TEAM){
            showGroupDetail(entity);
        } else if (websiteType == WebsiteInfoActivity.WEBSITE_FOR_ORGANIZE){
            showOrganization(entity);
        }

        //sensorEventListener = new JCVideoPlayer.JCAutoFullscreenListener();
        //binding.videoView.setUp(entity.getVideoUrl(), JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "企业视频");
        if (binding.smartRefresh.isRefreshing()) {
            binding.smartRefresh.finishRefresh(true);
        }
    }
    public static String ToDBC(String input) {
        char[] c = input.toCharArray();
        for (int i = 0; i< c.length; i++) {
            if (c[i] == 12288) {
                c[i] = (char) 32;
                continue;
            }if (c[i]> 65280&& c[i]< 65375)
                c[i] = (char) (c[i] - 65248);
        }
        return new String(c);
    }
    //根据业务类型动态切换提示
    private void changeViewTip(WebsiteInfoEntity.BusinessInfoEntity entity) {
        switch (entity.getType()){
            case 3://服务型
                binding.tvStaffTitle.setText("员工人数");
                binding.tvServiceRange.setText("服务范围");
                binding.tvServiceCustomer.setText("服务客户");
                binding.llServiceType.setVisibility(View.VISIBLE);
                binding.tvServiceType.setText("服务类型");
                binding.llProductArea.setVisibility(View.GONE);
                binding.tvArea.setText("服务地区");
                break;
            case 4://批发型
                binding.tvStaffTitle.setText("员工人数");
                binding.tvServiceRange.setText("批发范围");
                binding.tvServiceCustomer.setText("主营品牌");
                binding.llServiceType.setVisibility(View.GONE);
                binding.llProductArea.setVisibility(View.GONE);
                binding.tvArea.setText("批发地区");

                break;
            case 5://零售型
                binding.tvStaffTitle.setText("员工人数");
                binding.tvServiceRange.setText("零售范围");
                binding.tvServiceCustomer.setText("零售品牌");
                binding.llServiceType.setVisibility(View.GONE);
                binding.llProductArea.setVisibility(View.GONE);
                binding.tvArea.setText("零售地区");

                break;
            case 0://生产型
                binding.tvStaffTitle.setText("员工人数");
                binding.tvServiceRange.setText("生产范围");
                binding.tvServiceCustomer.setText("主营品牌");
                binding.llServiceType.setVisibility(View.GONE);
                binding.llProductArea.setVisibility(View.VISIBLE);
                binding.tvArea.setText("主营市场");
                break;
            case 1://研发型
                binding.tvStaffTitle.setText("研发人数");
                binding.tvServiceRange.setText("研发范围");
                binding.tvServiceCustomer.setText("研发产品");
                binding.llServiceType.setVisibility(View.VISIBLE);
                binding.tvServiceType.setText("客户类型");
                binding.llProductArea.setVisibility(View.GONE);
                binding.tvArea.setText("服务地区");
                break;
            case 2://贸易型
                binding.tvStaffTitle.setText("员工人数");
                binding.tvServiceRange.setText("贸易范围");
                binding.tvServiceCustomer.setText("贸易品牌");
                binding.llServiceType.setVisibility(View.GONE);
                binding.llProductArea.setVisibility(View.GONE);
                binding.tvArea.setText("主营市场");
                break;
        }


    }

    private List<PickFilterEntity> areas = new ArrayList<>();

    private void renderView(WebsiteInfoEntity.BusinessInfoEntity entity, int type) {
        if (TextUtils.isEmpty(entity.typeName)) {//业务信息
            binding.tvBusiness.setText(noData);
        } else {
            binding.tvBusiness.setText(entity.typeName);
        }
        String peopleNum = "";
        String annualIncome = "";
        String scope = "";
        String describe = "";
        areas.clear();
        if (type == 0) { //生产型
            peopleNum = entity.staffNumber;
            annualIncome = entity.annualIncome;
            if (TextUtils.isEmpty(entity.dayProduction)) {//日产量
                binding.tvDayOutput.setText(noData);
            } else {
                binding.tvDayOutput.setText(entity.dayProduction + (TextUtils.isEmpty(entity.unit) ? "吨" :entity.unit));
            }
            if (entity.productionRate == 0.00) {//制成率
                binding.tvProductionRate.setText(noData);
            } else {
                binding.tvProductionRate.setText(entity.getRate() + "%");
            }
            if (TextUtils.isEmpty(entity.factoryArea)) {//场地面积
                binding.tvProductionPlaceArea.setText(noData);
            } else {
                binding.tvProductionPlaceArea.setText(entity.factoryArea + "平方米");
            }
            scope = entity.productionScope;
            if (TextUtils.isEmpty(entity.getNames(entity.productionArea))) {//生产区域
                binding.tvProductArea.setText(noData);
            } else {
                binding.tvProductArea.setText(entity.getNames(entity.productionArea));
            }
            describe = entity.majorBrand;
            areas.addAll(entity.mainMarket == null ? new ArrayList<>() : entity.mainMarket);
        } else if (type == 1) {//研发型
            peopleNum = entity.researchNum;
            annualIncome = entity.annualIncome;
            scope = entity.researchRange;
            describe = entity.researchProduct;
            if (TextUtils.isEmpty(entity.customerType)) {//客户类型
                binding.tvServiceTypeContent.setText(noData);
            } else {
                binding.tvServiceTypeContent.setText(entity.customerType);
            }
            areas.addAll(entity.serviceArea == null ? new ArrayList<>() : entity.serviceArea);
        } else if (type == 2) {//贸易型
            peopleNum = entity.staffNumber;
            annualIncome = entity.annualIncome;
            if (TextUtils.isEmpty(entity.factoryArea)) {//贸易场地面积
                binding.tvTradePlaceArea.setText(noData);
            } else {
                binding.tvTradePlaceArea.setText(entity.factoryArea + "平方米");
            }
            if (TextUtils.isEmpty(entity.tradeAmount)) {//贸易量
                binding.tvTradeVolume.setText(noData);
            } else {
                binding.tvTradeVolume.setText(entity.tradeAmount + "次");
            }
            scope = entity.tradeScope;
            describe = entity.tradeBrand;
            areas.addAll(entity.tradeRegion == null ? new ArrayList<>() : entity.tradeRegion);
        } else if (type == 3) {//服务型
            peopleNum = entity.staffNumber;
            annualIncome = entity.annualIncome;
            scope = entity.serviceScope;
            describe = entity.serviceCustomer;
            if (TextUtils.isEmpty(entity.serviceType)) {//服务类型
                binding.tvServiceTypeContent.setText(noData);
            } else {
                binding.tvServiceTypeContent.setText(entity.serviceType);
            }
            areas.addAll(entity.serviceArea == null ? new ArrayList<>() : entity.serviceArea);
        } else if (type == 4) {
            peopleNum = entity.staffNumber;
            annualIncome = entity.annualIncome;
            if (TextUtils.isEmpty(entity.wholesaleOrder)) {//批发订单
                binding.tvWholesaleOrder.setText(noData);
            } else {
                binding.tvWholesaleOrder.setText(entity.wholesaleOrder + "单");
            }
            if (TextUtils.isEmpty(entity.purchaseOrder)) {//采购订单
                binding.tvWholesalePurchaseOrder.setText(noData);
            } else {
                binding.tvWholesalePurchaseOrder.setText(entity.purchaseOrder + "单");
            }
            if (TextUtils.isEmpty(entity.factoryArea)) {//场地面积
                binding.tvWholesalePlaceArea.setText(noData);
            } else {
                binding.tvWholesalePlaceArea.setText(entity.factoryArea + "平方米");
            }
            scope = entity.wholesaleScope;
            describe = entity.majorBrand;
            areas.addAll(entity.wholesaleArea == null ? new ArrayList<>() : entity.wholesaleArea);

        } else if (entity.getType() == 5) {
            peopleNum = entity.staffNumber;
            annualIncome = entity.annualIncome;
            if (TextUtils.isEmpty(entity.retailOrder)) {//零售订单
                binding.tvRetailOrder.setText(noData);
            } else {
                binding.tvRetailOrder.setText(entity.retailOrder + "单");
            }
            if (TextUtils.isEmpty(entity.retailOrder)) {//零售门店
                binding.tvRetailStore.setText(noData);
            } else {
                binding.tvRetailStore.setText(entity.retailStores);
            }

            if (TextUtils.isEmpty(entity.monthTurnover)) {//月营业额
                binding.tvRetailBusinessVolumeMonth.setText(noData);
            } else {
                binding.tvRetailBusinessVolumeMonth.setText(entity.monthTurnover + "万元");
            }
            scope = entity.retailScope;
            describe = entity.retailBrand;
            areas.addAll(entity.retailArea == null ? new ArrayList<>() : entity.retailArea);
        }
        if (TextUtils.isEmpty(peopleNum)) {//员工人数
            binding.tvStaffNum.setText(noData);
        } else {
            binding.tvStaffNum.setText(peopleNum);
        }
        if (TextUtils.isEmpty(annualIncome)) {//年营业额
            binding.tvBusinessVolume.setText(noData);
        } else {
            binding.tvBusinessVolume.setText(annualIncome + "万元");
        }
        if (TextUtils.isEmpty(scope)) {//范围
            binding.tvServiceRangeContent.setText(noData);
        } else {
            binding.tvServiceRangeContent.setText(scope);
        }
        if (TextUtils.isEmpty(describe)) {//描述
            binding.tvServiceCustomerContent.setText(noData);
        } else {
            binding.tvServiceCustomerContent.setText(describe);
        }
        if (TextUtils.isEmpty(entity.getNames(areas))) {//地区
            binding.tvAreaContent.setText(noData);
        } else {
            binding.tvAreaContent.setText(entity.getNames(areas));
        }
        if (entity.customFields != null) {
            binding.addView.setData(entity.customFields);
        }
    }

    private void showOrganization(WebsiteInfoEntity entity) {
        organizationMsgBinding.setViewModel(entity);
        if (TextUtils.isEmpty(entity.getOrganizationName())) {
            organizationMsgBinding.tvOrganizationName.setText(noData);
        } else {
            organizationMsgBinding.tvOrganizationName.setText(entity.getOrganizationName());
        }
        if (TextUtils.isEmpty(entity.getOrganizers())) {
            organizationMsgBinding.tvOrganizer.setText(noData);
        } else {
            organizationMsgBinding.tvOrganizer.setText(entity.getOrganizers());
        }
        if (TextUtils.isEmpty(entity.getInstitutionalTypeName())) {
            organizationMsgBinding.tvIndustryCategory.setText(noData);
        } else {
            organizationMsgBinding.tvIndustryCategory.setText(entity.getInstitutionalTypeName());
        }
        if (TextUtils.isEmpty(entity.getFixedPhone())) {
            organizationMsgBinding.tvFixedNumber.setText(noData);
        } else {
            organizationMsgBinding.tvFixedNumber.setText(entity.getFixedPhone());
        }
        if (TextUtils.isEmpty(entity.getContactPerson())) {
            organizationMsgBinding.tvConcat.setText(noData);
        } else {
            organizationMsgBinding.tvConcat.setText(entity.getContactPerson());
        }
        if (TextUtils.isEmpty(entity.getContactPhone())) {
            organizationMsgBinding.tvPhone.setText(noData);
        } else {
            organizationMsgBinding.tvPhone.setText(entity.getContactPhone());
        }

        if (TextUtils.isEmpty(entity.getAddress())) {
            organizationMsgBinding.tvAddress.setText(noData);
        } else {
            organizationMsgBinding.tvAddress.setText(entity.getAddress());
        }
        if (TextUtils.isEmpty(entity.getRegistrationDepartment())) {
            organizationMsgBinding.tvDepartment.setText(noData);
        } else {
            organizationMsgBinding.tvDepartment.setText(entity.getRegistrationDepartment());
        }
        if (TextUtils.isEmpty(entity.getBusinessScope())) {
            organizationMsgBinding.tvBusinessScope.setText(noData);
        } else {
            organizationMsgBinding.tvBusinessScope.setText(entity.getBusinessScope());
        }
        if (TextUtils.isEmpty(entity.getPurpose())) {
            organizationMsgBinding.tvPurpose.setText(noData);
        } else {
            organizationMsgBinding.tvPurpose.setText(entity.getPurpose());
        }
        if (TextUtils.isEmpty(entity.getIntroduction())) {
            organizationMsgBinding.tvIntroduction.setText(noData);
            organizationMsgBinding.linIntroduction.setVisibility(View.GONE);
        } else {
            organizationMsgBinding.linIntroduction.setVisibility(View.VISIBLE);
            String des = ReplaceUtils.INSTANCE.getHtml(entity.getIntroduction());
            organizationMsgBinding.tvIntroduction.setText(Html.fromHtml(
                    des, new MImgGetter(getContext(), organizationMsgBinding.tvIntroduction), null
            ));
        }
        organizationMsgBinding.rlVideoView.setOnClickListener(v -> {
            WebsiteUtils.getInstance().openVideo(getContext(), entity.getVideo(), entity.getVideoUrl(), entity.getCoverUrl());
        });
    }


    private void refreshView() {
        viewModel.getWebsiteInfo(websiteNo, websiteType);
    }


    public void showGroupDetail(WebsiteInfoEntity entity) {
        groupMsgBinding.setViewModel(entity);
        groupMsgBinding.tvManageBusiness.setText(entity.getNewMainBusinessName());
        //groupMsgBinding.tvGroupAddress.setText(getResources().getString(R.string.group_manage_address,
        //TextUtils.isEmpty(entity.getBusinessAddress()) ?  "-" : entity.getBusinessAddress()));
//groupMsgBinding.tvManageBusiness.setText(getResources().getString(R.string.group_manage_business,
        //TextUtils.isEmpty(entity.getMainBusiness()) ? "-" : entity.getMainBusiness()));
        //setAvatarView(entity.getLogo(), groupMsgBinding.ivGroup, true);
        if (TextUtils.isEmpty(entity.getTeamDes())){
            groupMsgBinding.tvDescribe.setText(noData);
        } else {
            String des = ReplaceUtils.INSTANCE.getHtml(entity.getTeamDes());
            groupMsgBinding.tvDescribe.setText(Html.fromHtml(des, new MImgGetter(getContext(), groupMsgBinding.tvDescribe), null));
        }
        if (entity.getServiceCityName() != null && !entity.getServiceCityName().isEmpty()) {
            StringBuilder sb = new StringBuilder();
            for (String item : entity.getServiceCityName()){
                sb.append(item).append(",");
            }
            groupMsgBinding.tvServiceCity.setText(sb.substring(0, sb.length() - 1));
        }  else {
            groupMsgBinding.tvServiceCity.setText("-");
        }
        //mTagAdapter = new TagAdapter(getContext(), R.layout.item_tag_group_info, new ArrayList());
        //groupMsgBinding.recyclerViewTag.setAdapter(mTagAdapter);
//        if (!TextUtils.isEmpty(entity.getBusinessType())) {
//            mTagAdapter.setDatas(Arrays.asList(entity.getBusinessType().split(",")));
//        }
//        if (binding.smartRefresh.isRefreshing()) {
//            binding.smartRefresh.finishRefresh(true);
//        }
    }
}

